home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / wiping.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  5KB  |  228 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. static int flipscreen;
  14.  
  15.  
  16. /***************************************************************************
  17.  
  18.   Convert the color PROMs into a more useable format.
  19.  
  20. ***************************************************************************/
  21.  
  22. void wiping_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  23. {
  24.     int i;
  25.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  26.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + (offs)])
  27.  
  28.  
  29.     for (i = 0;i < Machine->drv->total_colors;i++)
  30.     {
  31.         int bit0,bit1,bit2;
  32.  
  33.  
  34.         /* red component */
  35.         bit0 = (*color_prom >> 0) & 0x01;
  36.         bit1 = (*color_prom >> 1) & 0x01;
  37.         bit2 = (*color_prom >> 2) & 0x01;
  38.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  39.         /* green component */
  40.         bit0 = (*color_prom >> 3) & 0x01;
  41.         bit1 = (*color_prom >> 4) & 0x01;
  42.         bit2 = (*color_prom >> 5) & 0x01;
  43.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  44.         /* blue component */
  45.         bit0 = 0;
  46.         bit1 = (*color_prom >> 6) & 0x01;
  47.         bit2 = (*color_prom >> 7) & 0x01;
  48.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  49.  
  50.         color_prom++;
  51.     }
  52.  
  53.     /* color_prom now points to the beginning of the lookup table */
  54.  
  55.     /* chars use colors 0-15 */
  56.     for (i = 0;i < TOTAL_COLORS(0);i++)
  57.         COLOR(0,i ^ 3) = *(color_prom++) & 0x0f;
  58.  
  59.     /* sprites use colors 16-31 */
  60.     for (i = 0;i < TOTAL_COLORS(1);i++)
  61.         COLOR(1,i ^ 3) = (*(color_prom++) & 0x0f) + 0x10;
  62. }
  63.  
  64.  
  65.  
  66. WRITE_HANDLER( wiping_flipscreen_w )
  67. {
  68.     if (flipscreen != (data & 1))
  69.     {
  70.         flipscreen = (data & 1);
  71.         memset(dirtybuffer,1,videoram_size);
  72.     }
  73. }
  74.  
  75.  
  76.  
  77. /***************************************************************************
  78.  
  79.   Draw the game screen in the given osd_bitmap.
  80.   Do NOT call osd_update_display() from this function, it will be called by
  81.   the main emulation engine.
  82.  
  83. ***************************************************************************/
  84. void wiping_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  85. {
  86.     int offs;
  87.  
  88.     for (offs = videoram_size - 1; offs > 0; offs--)
  89.     {
  90.         if (dirtybuffer[offs])
  91.         {
  92.             int mx,my,sx,sy;
  93.  
  94.             dirtybuffer[offs] = 0;
  95.  
  96.             mx = offs % 32;
  97.             my = offs / 32;
  98.  
  99.             if (my < 2)
  100.             {
  101.                 sx = my + 34;
  102.                 sy = mx - 2;
  103.             }
  104.             else if (my >= 30)
  105.             {
  106.                 sx = my - 30;
  107.                 sy = mx - 2;
  108.             }
  109.             else
  110.             {
  111.                 sx = mx + 2;
  112.                 sy = my - 2;
  113.             }
  114.  
  115.             if (flipscreen)
  116.             {
  117.                 sx = 35 - sx;
  118.                 sy = 27 - sy;
  119.             }
  120.  
  121.             drawgfx(tmpbitmap,Machine->gfx[0],
  122.                     videoram[offs],
  123.                     colorram[offs] & 0x3f,
  124.                     flipscreen,flipscreen,
  125.                     sx*8,sy*8,
  126.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  127.             }
  128.     }
  129.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  130.  
  131.     /* Note, we're counting up on purpose ! */
  132.     /* This way the vacuum cleaner is always on top */
  133.     for (offs = 0x0; offs < 128; offs += 2) {
  134.         int sx,sy,flipx,flipy,otherbank;
  135.  
  136.         sx = spriteram[offs+0x100+1] + ((spriteram[offs+0x81] & 0x01) << 8) - 40;
  137.         sy = 224 - spriteram[offs+0x100];
  138.  
  139.         otherbank = spriteram[offs+0x80] & 0x01;
  140.  
  141.         flipy = spriteram[offs] & 0x40;
  142.         flipx = spriteram[offs] & 0x80;
  143.  
  144.         if (flipscreen)
  145.         {
  146.             sy = 208 - sy;
  147.             flipx = !flipx;
  148.             flipy = !flipy;
  149.         }
  150.  
  151.         drawgfx(bitmap,Machine->gfx[1],
  152.             (spriteram[offs] & 0x3f) + 64 * otherbank,
  153.             spriteram[offs+1] & 0x3f,
  154.             flipx,flipy,
  155.             sx,sy,
  156.             &Machine->drv->visible_area,TRANSPARENCY_COLOR,0x1f);
  157.     }
  158.  
  159.     /* redraw high priority chars */
  160.     for (offs = videoram_size - 1; offs > 0; offs--)
  161.     {
  162.         if (colorram[offs] & 0x80)
  163.         {
  164.             int mx,my,sx,sy;
  165.  
  166.             mx = offs % 32;
  167.             my = offs / 32;
  168.  
  169.             if (my < 2)
  170.             {
  171.                 sx = my + 34;
  172.                 sy = mx - 2;
  173.             }
  174.             else if (my >= 30)
  175.             {
  176.                 sx = my - 30;
  177.                 sy = mx - 2;
  178.             }
  179.             else
  180.             {
  181.                 sx = mx + 2;
  182.                 sy = my - 2;
  183.             }
  184.  
  185.             if (flipscreen)
  186.             {
  187.                 sx = 35 - sx;
  188.                 sy = 27 - sy;
  189.             }
  190.  
  191.             drawgfx(bitmap,Machine->gfx[0],
  192.                     videoram[offs],
  193.                     colorram[offs] & 0x3f,
  194.                     flipscreen,flipscreen,
  195.                     sx*8,sy*8,
  196.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  197.             }
  198.     }
  199.  
  200.  
  201. #if 0
  202. {
  203.     int i,j;
  204.     extern unsigned char *wiping_soundregs;
  205.  
  206.     for (i = 0;i < 8;i++)
  207.     {
  208.         for (j = 0;j < 8;j++)
  209.         {
  210.             char buf[40];
  211.             sprintf(buf,"%01x",wiping_soundregs[i*8+j]&0xf);
  212.             ui_text(buf,j*10,i*8);
  213.         }
  214.     }
  215.  
  216.     for (i = 0;i < 8;i++)
  217.     {
  218.         for (j = 0;j < 8;j++)
  219.         {
  220.             char buf[40];
  221.             sprintf(buf,"%01x",wiping_soundregs[0x2000+i*8+j]>>4);
  222.             ui_text(buf,j*10,80+i*8);
  223.         }
  224.     }
  225. }
  226. #endif
  227. }
  228.